package com.springboot.elaticsearch.demo.controller;

import com.springboot.elaticsearch.demo.service.ContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import com.springboot.elaticsearch.demo.service.impl.ContentServiceImpl;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @Author: jxm
 * @Description:
 * @Date: 2023/2/28 21:53
 * @Version: 1.0
 */
@RestController
public class ContentController {

    @Autowired
    ContentService contentService;

    @GetMapping("/save/{keyword}")
    public boolean parse(@PathVariable("keyword") String keyword) throws IOException {
        return contentService.saveData(keyword);
    }

    @GetMapping("/search/{keyword}/{pageNo}/{pageSize}")
    public List<Map<String,Object>> search(@PathVariable("keyword") String keyword,
                                           @PathVariable("pageNo") Integer pageNo,
                                           @PathVariable("pageSize") Integer pageSize) throws IOException {
        return contentService.search(keyword,pageNo,pageSize);
    }

//    @GetMapping("/h_search/{keyword}")
//    public boolean hSearch(@PathVariable("keyword") String keyword) throws IOException {
//        contentService.search(keyword);
//        return false;
//    }
}
